package com.longdaji.decoration.ui.activitiesOfCommunity.publishDynamic.addLabel;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.longdaji.decoration.R;
import com.longdaji.decoration.base.BaseActivity;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AddLabelActivity extends BaseActivity implements AddLabelContract.View {
    @Inject
    AddLabelContract.Presenter mPresenter;

    @BindView(R.id.flow_layout)
    TagFlowLayout flowLayout;

    private LayoutInflater mInflater;
    private List<String> mLabels = new ArrayList<>();
    private TagAdapter mTagAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_label);
        setUnBinder(ButterKnife.bind(this));

        mLabels.add("hahaha");
        mLabels.add("wawawa");
        mLabels.add("yayaya");

        mInflater = LayoutInflater.from(this);
        mTagAdapter = new TagAdapter<String>(mLabels) {
            @Override
            public View getView(FlowLayout parent, int position, String s) {
                TextView tvLabel = (TextView) mInflater.inflate(R.layout.label, flowLayout, false);
                tvLabel.setText(s);
                return tvLabel;
            }
        };
        flowLayout.setAdapter(mTagAdapter);
        flowLayout.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
            @Override
            public boolean onTagClick(View view, int position, FlowLayout parent) {
                // TODO: 2018/3/7 0007 onClick
                return true;
            }
        });
        flowLayout.setOnSelectListener(new TagFlowLayout.OnSelectListener() {
            @Override
            public void onSelected(Set<Integer> selectPosSet) {
                // TODO: 2018/3/7 0007 onSelect
            }
        });
    }
}
